import { getLoginInfo, getLoginToken, getWXLoginInfo, getDoctorQualificationInfo, getDoctorProjectData } from "@/utils/auth"

const getDefaultState = () => {
	return {
		token: getLoginToken(),
		unreadMessageCount: 0,
		userInfo: getLoginInfo(),
		WXuserInfo: getWXLoginInfo(),
		doctorQualificationInfo: getDoctorQualificationInfo(),
		doctorProjectData: getDoctorProjectData(),
	}
}

const state = getDefaultState()

const mutations = {
	setUserInfo(state, userInfo) {
		state.userInfo = userInfo
		state.token = userInfo.tokenValue
	},
	setWXuserInfo(state, userInfo) {
		state.WXuserInfo = userInfo
	},
	resetUserInfo(state) {
		state.token = ''
		state.userInfo = {}
		state.WXuserInfo = {}
		state.doctorQualificationInfo = {}
		state.doctorProjectData = {}
	},
	changeCertificationStatus(state, status) {
		state.userInfo.certificationStatus = status
	},
	setDoctorQualificationInfo(state, info) {
		state.doctorQualificationInfo = info
	},
	setDoctorProjectData(state, data) {
		state.doctorProjectData = data
	},
	setUnreadMessageCount(state, count) {
		state.unreadMessageCount = count
	},
	addUnreadMessageCount(state, count) {
		state.unreadMessageCount += count;
	},
	reduceUnreadMessageCount(state, count) {
		state.unreadMessageCount -= count;
	}
};

const actions = {
	logout({ commit, state }) {},
};

export default {
	namespaced: true,
	state,
	mutations,
	actions
}